#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;

  // counter[x] : the number of i satisfying x = i + A[i]
  map<int, int> counter;

  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  long long ans = 0;
  for (int i = 0; i < N; ++i) {

    ans += counter[i - a[i]];
    // increment the counter for j + A[j]
    ++counter[i + a[i]];
  }
  cout << ans << endl;
  return 0;
}
